package com.csaba.connector;

import com.csaba.connector.model.Bank;

/**
 * This interface is used to identify bank plugins. 
 * <p> Plugins are loaded by the mechanism of the java.util.ServiceLoader.
 * <p> Automatic service instantiation is implemented by the BankServiceFactory,
 * if the naming conventions of the service classes are followed. However the 
 * plugin may decide on producing service instances in different way using
 * the {@link #getBankService(Class)} method.
 * <p> Naming convetion of the bank services: [service-package].[service-prefix][service-name]
 * <p> For example the AccountService in the OTP bank (service-package = com.csaba.connector.otp; 
 * service-prefix=OTP): com.csaba.connector.otp.OTPAccountService.
 * 
 * @see com.csaba.connector.BankServiceFactory
 * @author Gabe
 *
 */
public interface ServicePluginConfiguration
{
	/**
	 * Returns Bank describing the bank. 
	 * @return object describing the bank.
	 */
	public Bank getBank();

	/**
	 * Name of the package where the service implementation classes can be found.
	 * This method is used for automatic service instantiation.
	 * @return Name of the service package.
	 */
	public String getServicePackage();

	/**
	 * Service name prefix. This method is used for automatic service instantiation.
	 * @return Prefix used in service names.
	 */
	public String getServicePrefix();

	/**
	 * Custom plugin instantiation method. Use this method, if no automatic 
	 * instantiation is preferred in the plugin implementation.
	 * @param serviceClass Class of the required service interface, e.g.: AccountService.class.
	 * @return Nwe instance of a service class.
	 * @throws ServiceException
	 */
	public BankService getBankService( Class<?> serviceClass ) throws ServiceException;
}
